//
//  AXYxtyIntroduceTableViewCell.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/10/12.
//  Copyright © 2018年 tzhg. All rights reserved.
//

#import "AXYxtyIntroduceTableViewCell.h"
#import "UIView+SDAutoLayout.h"
#import "ZXCategories.h"
#import "UITableView+SDAutoTableViewCellHeight.h"

@interface AXYxtyIntroduceTableViewCell ()
/** 标题 */
@property (nonatomic ,strong) UILabel *titleLabel;
/** 价格*/
@property (nonatomic ,strong) UILabel *priceLabel;
/** 规则*/
@property (nonatomic ,strong) UILabel *ruleLabel;
/**活动时间 */
@property (nonatomic ,strong) UILabel *activityTimeLabel;
/**发货时间 */
@property (nonatomic ,strong) UILabel *goodsLabel;


@end


@implementation AXYxtyIntroduceTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self creatView];
        [self setlayout];
    }
    return self;
}

- (void)creatView {
    /** title */
    self.titleLabel = [[UILabel alloc]init];
    self.titleLabel.text = @"云南新鲜玉米水果s玉米 甜玉米 鲜玉米 棒八斤装爆浆玉米粒甜脆可口可生吃";
    self.titleLabel.font = [UIFont systemFontOfSize:18];
    [self.contentView addSubview:self.titleLabel];
    /** 价格 */
    self.priceLabel = [[UILabel alloc]init];
    self.priceLabel.text = @"¥98.0";
    self.priceLabel.font = [UIFont systemFontOfSize:22];
    self.priceLabel.textColor = [UIColor orangeColor];
    [self.contentView addSubview:self.priceLabel];
    
    /** 规则 */
    self.ruleLabel = [[UILabel alloc]init];
    self.ruleLabel.text = @"规则";
    self.ruleLabel.font = [UIFont systemFontOfSize:16];
    self.ruleLabel.textColor = [UIColor blackColor];
    [self.contentView addSubview:self.ruleLabel];
    
    
    /** 富文本 */
    NSMutableAttributedString  *mString = [[  NSMutableAttributedString  alloc]init];
    NSAttributedString *str = [[ NSAttributedString alloc]initWithString:@"活动时间 : " attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:[UIColor blackColor]}];
    [mString appendAttributedString:str];
    
    NSAttributedString *str1 = [[ NSAttributedString alloc]initWithString:@" 2018.10.01-2018.10.07" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:[UIColor orangeColor]}];
    [mString appendAttributedString:str1];
    self.activityTimeLabel = [[UILabel alloc]init];
    self.activityTimeLabel.font = [UIFont systemFontOfSize:18];
    self.activityTimeLabel.attributedText = mString;//把字符串加到prepareLessonLabel上
    [self.contentView addSubview:self.activityTimeLabel];
    
    /** 富文本 */
    NSMutableAttributedString  *timeString = [[  NSMutableAttributedString  alloc]init];
    NSAttributedString *timeStr = [[ NSAttributedString alloc]initWithString:@"统一发货时间 : " attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:[UIColor blackColor]}];
    [timeString appendAttributedString:timeStr];
    
    NSAttributedString *str2 = [[ NSAttributedString alloc]initWithString:@" 2018.10.01-2018.10.07" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:[UIColor orangeColor]}];
    [timeString appendAttributedString:str2];
    
    self.goodsLabel = [[UILabel alloc]init];
    self.goodsLabel.attributedText = timeString;//把字符串加到prepareLessonLabel上
    self.goodsLabel.font = [UIFont systemFontOfSize:18];
    [self.contentView addSubview:self.goodsLabel];
    
    
    
   
}

- (void)setlayout {
    self.titleLabel.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 10)
    .widthIs(SCREEN_WIDTH-20)
    .autoHeightRatio(0);
    
    self.priceLabel.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.titleLabel, 10)
    .widthIs(200)
    .heightIs(30);
    
    self.ruleLabel.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.priceLabel, 10)
    .widthIs(100)
    .heightRatioToView(self.priceLabel, 1);
    
    self.activityTimeLabel.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.ruleLabel, 10)
    .widthIs(SCREEN_WIDTH -20)
    .heightRatioToView(self.ruleLabel, 1);
    
    self.goodsLabel.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.activityTimeLabel, 10)
    .widthIs(SCREEN_WIDTH-20)
    .heightRatioToView(self.ruleLabel, 1);
    
    [self setupAutoHeightWithBottomView:self.goodsLabel bottomMargin:10];
}

@end
